<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class gioithieu_model extends CI_Model
{
	function __construct()
	{
		parent::__construct();
		$this->load->library('unicode');
	}
	
	public function select()
	{
		$query = $this->db->query("SELECT noidung FROM gioithieu WHERE id = 1");
		return $query->row()->noidung;
	}
	
	public function update($noidung)
	{
		$chk = $this->security->xss_clean($noidung);
		if($chk == $noidung)
		{
			$noidung = $this->unicode->unicode2database($noidung);
			$this->db->query("UPDATE gioithieu SET noidung = ? WHERE id = 1", array($noidung));
			$chk = $this->db->query("SELECT id FROM gioithieu WHERE id = 1 AND noidung = ?", array($noidung));
			if($chk->num_rows() > 0) return TRUE;
		}
		return FALSE;
	}
}